package acwing.动态规划;

import java.util.Scanner;

/**
 * 最长上升子序列
 *
 * @author yang
 * @date 2021/11/22
 */
public class 最长上升子序列 {

    static int N = 1010, n;
    static int[] w = new int[N];
    static int[] f = new int[N];

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        for (int i = 1; i <= n; i++) {
            w[i] = s.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            f[i] = 1;
            for (int j = 1; i < j; j++) {
                if (w[i] > w[j]) f[i] = Math.max(f[i], f[j] + 1);
            }
        }
        int res = 0;
        for (int i = 1; i <= n; i++) res = Math.max(res, f[i]);
        System.out.println(res);
    }
}
